#include <linux/module.h> // module_init, module_exit
#include "git_version.h"

static char *version = GIT_VERSION;
module_param(version, charp, S_IRUGO);
MODULE_PARM_DESC(version, "this is a note for helloclass"); // only show in modinfo

static int debug = 1;
module_param(debug, int, 0644);
MODULE_PARM_DESC(version, "printk debug level");

#define dprintk(level, fmt, arg...)                     \
    do {                                                \
        if (debug >= level)                             \
            printk(KERN_DEBUG "class: " fmt, ## arg);   \
    } while (0)


#define DRIVER_NAME     "class"
#define MAJOR           250

static int __init hello_init(void)
{
    dprintk(0, "class init.\n");
    if (register_chrdev(MAJOR, DRIVER_NAME, &memory_fops)) {
    }
    return 0;
}

static void __exit hello_exit(void)
{
    unregister_chrdev();
    dprintk(0, "class exit.\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Chongyu.Guo");
MODULE_DESCRIPTION("helloclass: test class. " GIT_VERSION);

